package thread.Test;

class task implements Runnable {

	private int ticket = 10;

	@Override
	public void run() {
		for (int i = 0; i < 20; i++) {
			if (this.ticket > 0) {
				System.out.println(Thread.currentThread().getName()
						+ " sold ticket " + this.ticket--);
			}
		}
	}

};


public class RunnableTest {
	public static void main(String[]args){
		task mytask = new task();
		Thread t1 = new Thread(mytask);
		Thread t2 = new Thread(mytask);
		Thread t3 = new Thread(mytask);
		t1.start();
		t2.start();
		t3.start();
	}

}
